<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>华富</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
</head>
<style>


    /***index_product***/
    .index_product{
      width: 100%;
    }
    .index_product_con{
      width: 100%;
      padding:0.4rem;
    }
    .index_product_list{
      width: 100%;
      background: #fff;
      border-radius: 0.5rem;
      overflow: hidden;
      margin-bottom: 0.4rem;
    }
    .index_product_zi{
      padding: 1.3rem 0.9rem;
    }
    .index_product_zi h5{
      font-size: 1.3rem;
      line-height: 1.2;
      color: #0a0a0a;
      margin-bottom: 1.2rem;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }
    .index_product_zi h5 font{
      display: inline-block;
      line-height: 1.5rem;
      font-size: 1rem;
      color: #fff;
      background: #ed6a20;
      border-radius: 0.2rem;
      margin-right: 0.2rem;
      padding: 0 0.4rem;
      vertical-align: top;
    }
    .index_product_zi p{
      font-size: 1.5rem;
      color: #f01818;
      line-height: 1.2;
    }
    .index_product_zi p span{
      float: right;
      line-height: 2rem;
      font-size: 1.1rem;
      color: #666666;
      border: 1px solid #999;
      padding: 0 1rem;
      border-radius: 2rem;
      position: relative;
      top: -0.2rem;
    }
    /***index_product***/


    /***search_wap***/
    .search_wap{
      width: 100%;
      padding-top: 6.5rem;
    }
    .search_wap_con{
      width: 100%;
      padding: 1.5rem 1.3rem;
      background: #fff;
    }

    .index_product_search .index_h5{
      background: #f5f5f5;
    }
    .search_wap_list{
      margin-bottom: 0.9rem;
    }
    .search_wap_list h5{
      font-size: 1.4rem;
      color: #000;
      line-height: 1;
      margin-bottom: 1.5rem;
    }
    .search_wap_list h5 span{
      float: right;
    }
    .search_wap_list h5 span img{
      width: 1.4rem;
    }
    .search_wap_list>span{
      display: inline-block;
      line-height: 3.2rem;
      padding: 0 1.6rem;
      border-radius: 3.2rem;
      background: #f5f5f5;
      font-size: 1.3rem;
      color: #333;
      margin-right: 0.6rem;
      margin-bottom: 0.9rem;
    }
    [v-cloak]{
      display: none;
    }
    /***search_wap***/


</style>
<body>
<div id="app" style="background: #f5f5f5;" v-cloak>

  <!--search-->
  <div class="search search_search">
    <div class="search_con">
      <div class="search_map" onclick="goBack()"><img src="../../image/back.png"></div>
      <div class="search_input">
        <input type="text" placeholder="搜索" id="inputText" v-model="inputValue">
        <div class="search_ss"><img src="../../image/search_icon2.png"></div>
        <div class="search_sm"><img src="../../image/search_icon1.png"></div>
      </div>
      <div class="search_info">
        <img src="../../image/search_info.png">
        <span>5</span>
      </div>
    </div>
  </div>
  <!--/search-->


  <div class="aui-refresh-content">



  <!--index_product-->
  <div class="index_product index_product_search">
    <h5 class="index_h5">服饰箱包</h5>
    <div class="index_product_con">
       <div class="row clearfix clm2">
         <div class="col-xs-6 clp2" v-for="item in msgList">
           <div class="index_product_list">
            <img :src=item.pic2_pc width="100%">
            <div class="index_product_zi">
              <h5><font>{{item.store_name}}</font>{{item.goods_name}}</h5>
              <p>¥{{item.goods_price}} <span>已售{{item.virtual_sales}}</span></p>
            </div>
           </div>
         </div>
       </div>
    </div>
  </div>
  <!--index_product-->
  </div>


</div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>


<script type="text/javascript">

  apiready = function(){
    setRefresh()
    var vm = new Vue({
      el:'#app',
      data:{
        page:1,
        allpage:1,
        msgList:[],
        inputValue:''
      },
      methods:{
        storeList:function(keyword){
          var _this = this
          this.inputValue = keyword
           _this.addAray(keyword)
          var data={
            token:$api.getStorage('token') || "",
            keywords:keyword,
            page:1
          }
          api.ajax({
              url: window.hurl.goodsList,
              method: 'post',
              data: {
                  values:data
              }
          },function(ret, err){
              if (ret) {
                  console.log( JSON.stringify( ret.all_page ) );
                  if(ret.status==1 || ret.status==0){
                    _this.msgList=ret.list
                    _this.allpage=ret.all_page
                    if(ret.list.length==0){
                      api.toast({
                          msg: '商品为空',
                          duration: 1000,
                          location: 'middle'
                      });
                    }
                  }else{
                    api.toast({
                        msg: '获取失败',
                        duration: 1000,
                        location: 'middle'
                    });
                  }
              } else {
                  console.log( JSON.stringify( err ) );
              }
          });
        },

        //输入
        inputMsg:function(){
          var _this = this
          $("#inputText").on("keypress",function(e){
            //console.log(e.keyCode)
              e.keyCode==13 ? _this.storeList($('#inputText').val()) : ''
          })
        },
        addAray:function(val){
          var $_this = this
          //检测到达底部添加下一页内容
          var scroll = new auiScroll({
              listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
              distance:40 //判断到达底部的距离，isToBottom为true
          },function(ret){
              if (ret.isToBottom) {
                  $_this.page ++
                  if ($_this.page > $_this.allpage) {
                      $_this.page = $_this.allpage
                      return
                  }
                  api.ajax({
                      url: window.hurl.goodsList,
                      method: 'post',
                      data: {
                          values:{token:$api.getStorage('token') || "",
                          keywords:val,
                          page:$_this.page}
                      },
                      timeout: 300,
                  }, function(ret, err) {
                      if (ret) {
                          //  api.alert({ msg: JSON.stringify(ret) });
                          $_this.msgList = $_this.msgList.concat(ret.list)

                      } else {
                          api.alert({ msg: JSON.stringify(err) });
                      }
                  })
              }

          })
        }
      },
      created:function(){
        api.showProgress({
            title: '努力加载中...',
            text: '先喝杯茶...',
            modal: false
        });

      },
      mounted:function(){
        api.hideProgress();
        this.storeList(api.pageParam.keyword)
        this.inputMsg()

      },
      filters:{},
      watch:{
        inputValue:function(e){
          if(e==""){
            this.storeList()
          }
        }
      }
    })

  }

  //刷新
  function setRefresh(){
      var pullRefresh = new auiPullToRefresh({
          container: document.querySelector('.aui-refresh-content'),
          triggerDistance: 100
      }, function(ret) {

          if (ret.status == "success") {
              setTimeout(function() {
                  pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
              }, 1500)
          }
      })
  }


  function goBack(){
    api.closeWin({

    });
  }



</script>
